﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using DPMP.DataAccess;

namespace DPMP.ViewModel
{
    public class PatternModelCollectionViewModel
    {
        #region Private Fields

        // list of all pattern models
        Collection<PatternModelViewModel> _patternModelList;

        // data access
        IDataAccess dataAccess;

        #endregion

        #region Constructors

        public PatternModelCollectionViewModel()
        {
            // initiate data access
            dataAccess = new DataAccess.DataAccess();
            
            // retrieve the list of all pattern model view models
            _patternModelList = new Collection<PatternModelViewModel>
            (
                (
                    from patternModel in dataAccess.GetAllPatternModel()
                    select new PatternModelViewModel(patternModel)
                )
                .ToList<PatternModelViewModel>()
            ); 
        }

        #endregion

        #region Properties

        public Collection<PatternModelViewModel> PatternModelList
        {
            get { return _patternModelList; }
        }

        #endregion
    }
}
